home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Mr. Do.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  3.8 KB  |  177 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define        BoxSize    4
  15. #define CorrectTime 1
  16.  
  17. void MrDo(GrafPtr);
  18.  
  19. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern
  20.    and alternatively scroll it up or down. */
  21.    
  22. void MrDo(GrafPtr sourceGrafPtr)
  23. {
  24.     int            x, y;
  25.     int            vgap,hgap;
  26.     Rect        theRect, dest;
  27.     Rect        scrollsource, scrolldest;
  28.     Rect        bounds[25];
  29.     Boolean        everyOther;
  30.     
  31.     vgap=MAIN_WINDOW_HEIGHT/5;
  32.     hgap=MAIN_WINDOW_WIDTH/5;
  33.     
  34.     for (x=0; x<25; x++)
  35.     {
  36.         switch (x)
  37.         {
  38.             case 0:
  39.             case 1:
  40.             case 2:
  41.             case 3:
  42.             case 4:
  43.                 bounds[x].top=0;
  44.                 break;
  45.             case 15:
  46.             case 16:
  47.             case 17:
  48.             case 18:
  49.             case 5:
  50.                 bounds[x].top=vgap;
  51.                 break;
  52.             case 14:
  53.             case 23:
  54.             case 24:
  55.             case 19:
  56.             case 6:
  57.                 bounds[x].top=vgap*2;
  58.                 break;
  59.             case 13:
  60.             case 22:
  61.             case 21:
  62.             case 20:
  63.             case 7:
  64.                 bounds[x].top=vgap*3;
  65.                 break;
  66.             case 12:
  67.             case 11:
  68.             case 10:
  69.             case 9:
  70.             case 8:
  71.                 bounds[x].top=vgap*4;
  72.                 break;
  73.         }
  74.         switch (x)
  75.         {
  76.             case 0:
  77.             case 15:
  78.             case 14:
  79.             case 13:
  80.             case 12:
  81.                 bounds[x].left=0;
  82.                 break;
  83.             case 1:
  84.             case 16:
  85.             case 23:
  86.             case 22:
  87.             case 11:
  88.                 bounds[x].left=hgap;
  89.                 break;
  90.             case 2:
  91.             case 17:
  92.             case 24:
  93.             case 21:
  94.             case 10:
  95.                 bounds[x].left=hgap*2;
  96.                 break;
  97.             case 3:
  98.             case 18:
  99.             case 19:
  100.             case 20:
  101.             case 9:
  102.                 bounds[x].left=hgap*3;
  103.                 break;
  104.             case 4:
  105.             case 5:
  106.             case 6:
  107.             case 7:
  108.             case 8:
  109.                 bounds[x].left=hgap*4;
  110.                 break;
  111.         }
  112.         bounds[x].bottom=bounds[x].top+vgap;
  113.         bounds[x].right=bounds[x].left+hgap;
  114.     }
  115.     
  116.     for (y=0; y<25; y++)
  117.     {        
  118.         if (y%2)   /* these scroll up */
  119.         {
  120.             scrollsource=bounds[y];
  121.             scrollsource.top+=BoxSize;
  122.             scrolldest=scrollsource;
  123.             OffsetRect(&scrolldest,0,-BoxSize);
  124.             
  125.             dest=bounds[y];
  126.             dest.top=dest.bottom-BoxSize;
  127.             
  128.             theRect=bounds[y];
  129.             theRect.bottom=theRect.top+BoxSize;
  130.             
  131.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  132.             {
  133.                 StartTiming();
  134.                 CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  135.                         &scrollsource, &scrolldest, 0, 0L);
  136.                 CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  137.                         &theRect, &dest, 0, 0L);
  138.                 theRect.bottom+=BoxSize;
  139.                 theRect.top+=BoxSize;
  140.                 if (everyOther)
  141.                     TimeCorrection(CorrectTime);
  142.                 everyOther=!everyOther;
  143.             }
  144.         }
  145.         else    /* these scroll down */
  146.         {
  147.             scrollsource=bounds[y];
  148.             scrollsource.bottom-=BoxSize;
  149.             scrolldest = scrollsource;
  150.             OffsetRect(&scrolldest, 0, BoxSize);
  151.             
  152.             dest=bounds[y];
  153.             dest.bottom=dest.top+BoxSize;
  154.             
  155.             theRect=bounds[y];
  156.             theRect.top=theRect.bottom-BoxSize;
  157.             
  158.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  159.             {
  160.                 StartTiming();
  161.                 CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  162.                         &scrollsource, &scrolldest, 0, 0L);
  163.                 CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  164.                         &theRect, &dest, 0, 0L);
  165.                 theRect.bottom-=BoxSize;
  166.                 theRect.top-=BoxSize;
  167.                 if (everyOther)
  168.                     TimeCorrection(CorrectTime);
  169.                 everyOther=!everyOther;
  170.             }
  171.         }
  172.         
  173.         CopyBits(&(sourceGrafPtr->portBits),&(gMainWindow->portBits),
  174.                     &bounds[y],&bounds[y],0,0L);
  175.     }
  176. }
  177.